package com.appbee.cm.client.event;

import com.google.web.bindery.event.shared.Event;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.HandlerRegistration;

public class EditModeChange extends Event<EditModeChange.Handler>
{

	public interface Handler
	{
		void onChange(EditModeChange event);
	}

	private static final Type<EditModeChange.Handler> TYPE = new Type<EditModeChange.Handler>();

	public static <P> HandlerRegistration registerForProxyType(	EventBus eventBus,
																EditModeChange.Handler handler)
	{
		return eventBus.addHandler(TYPE, handler);
	}

	private final boolean editMode;

	public EditModeChange(boolean editMode)
	{
		this.editMode = editMode;
	}

	@Override
	public Event.Type<Handler> getAssociatedType()
	{
		return TYPE;
	}

	public boolean isEditMode()
	{
		return editMode;
	}

	@Override
	protected void dispatch(Handler handler)
	{
		handler.onChange(this);
	}
}